package com.gxa.jd.controller;

import com.gxa.jd.pojo.GoodsOrderItem;
import com.gxa.jd.service.OrderItemService;
import com.gxa.entity.PageResult;
import com.gxa.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/orderItem")
public class OrderItemController {

    @Autowired
    private OrderItemService orderItemService;

    @GetMapping("/findAll")
    public List<GoodsOrderItem> findAll() {
        return orderItemService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<GoodsOrderItem> findPage(int page, int size) {
        return orderItemService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<GoodsOrderItem> findList(@RequestBody Map<String, Object> searchMap) {
        return orderItemService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<GoodsOrderItem> findPage(@RequestBody Map<String, Object> searchMap, int page, int size) {
        return orderItemService.findPage(searchMap, page, size);
    }

    @GetMapping("/findById")
    public GoodsOrderItem findById(Long id) {
        return orderItemService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody GoodsOrderItem orderItem) {
        orderItemService.add(orderItem);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody GoodsOrderItem orderItem) {
        orderItemService.update(orderItem);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id) {
        orderItemService.delete(id);
        return new Result();
    }

}
